﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using WebTranslator;

namespace TranslationClient
{
  public partial class DodawanieTlumaczenia : Form
  {
    string separator = "$$";
    CMSProtocolC cp;
    public DodawanieTlumaczenia(CMSProtocolC cp)
    {
      InitializeComponent();
      this.cp = cp;
    }

    private void button2_Click(object sender, EventArgs e)
    {
      textBox1.Text = textBox1.Text.Replace(separator, textBox2.Text);
      separator=textBox2.Text;
     
    }

    private void button4_Click(object sender, EventArgs e)
    {
       string tresc = textBox1.Text.Replace(Environment.NewLine, "//");
        string tyt = textBox5.Text.Replace(' ','_');
        string jez1 = textBox3.Text.Replace(' ','_');
        string jez2 = textBox4.Text.Replace(' ','_');
      cp.Send("tlumaczeniedodaj");
      cp.Send("tresc " + tresc);
      cp.Send("nazwa " + tyt);
      cp.Send("jezykwejscia "+jez1);
      cp.Send("jezykwyjscia " + jez2);
      cp.Send("separator " + textBox2.Text);
      cp.Send("tlok");
			Close();
    }

    private void button1_Click(object sender, EventArgs e)
    {
        string ss = "";
        for (int i = 0; i < textBox1.Text.Length; i++)
        {if (i == textBox1.SelectionStart) ss += separator; ss += textBox1.Text[i];  }
        textBox1.Text = ss;
    }

    
  }
}
